<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>

    <body style="padding-left: 50px">
    <h1>map</h1>
    <div>
        <ul>
            <li>map集合遍历</li>
            <#list map?keys as key>
                <font color="red">${key}:${map[key]}</font><br/>
            </#list>

        </ul>
    </div>

    <h1>if,else</h1>
    <div>
        <ul>
            <li>if</li>
           <#assign var=99/>
            <#if var==99>
                <font color="red">var=99</font><br>
            </#if>

            <#if var==99>
                <font color="aqua">var = 99</font><br>
            <#else>
                <font color="aqua">var !=99</font><br>
            </#if>

            <#if var &gt;99>
                <font color="red">var大于99</font><br>

            <#elseif var==99>
                <font color="red">var等于99</font><br>
            <#else>
                <font color="red">va小于99</font><br>
            </#if>




        </ul>
    </div>

    <h1>if,else</h1>
    <div>
        <ul>
            <li>多条件判断</li>
            <#assign var='python'/>
            <#if var=='python'&&var?length==6>
                <font color="red">python</font><br>
            </#if>

        </ul>
    </div>

    <h1>String</h1>
    <div>
        <ul>
            <li>字符串操作</li>
            <#assign a='python'/>
            <#assign b="helolo"/>
            <li>连接</li>
            <font color="red">${a+b}</font><br>
            <li>截取</li>
            <font color="red">${(a+b)?substring(5,8)}</font><br>
            <li>长度</li>
            <font color="red">${(a+b)?length}</font><br>
            <li>大写</li>
            <font color="red">${(a+b)?upper_case}</font><br>
            <li>小写</li>
            <font color="red">${(a+b)?lower_case}</font><br>
            <li>index_of</li>
            <font color="red">${(a+b)?index_of('h')}</font><br>
            <li>last-index_of</li>
            <font color="red">${(a+b)?last_index_of('h')}</font><br>
            <li>replace</li>
            <font color="red">${(a+b)?replace('o','xxx')}</font><br>

        </ul>
    </div>

    <div>
        <h2>内建函数</h2>
        <ul>
            <li>split</li>
            <#assign var='a|b|c|d'/>
            <li>未分割前</li>
            <font color="red">${var}:</font><br>
            <li>分割后</li>
            <#list var?split("|") as item>
                <font color="aqua">${item},</font><br>
            </#list>


        </ul>

        <ul>

            <li>字符转日期</li>
            <#assign var1="01/02/2017"?date("MM/dd/yyyy")/>
            <#assign var2="15:05:30"?time("HH:mm:ss")/>
            <#assign var3="2017-11-11 08:05 PM"?datetime("yyyy-MM-dd hh:mm")/>
            <font color="red">${var}:</font><br>
            <li>01/02/2017---></li>
            <li>${var1}</li>
            <li>15:05:30---></li>
            <li>${var2}</li>
            <li>2017-11-11 08:05 PM---></li>
            <li>${var3}</li>


        </ul>

        <ul>

            <li>数字类型内建函数</li>
            <#assign var=3.1415526/>
            <li>${var?string("0.##")}</li>
            <li>${var?round}</li>
        </ul>

        <ul>

            <li>list内建函数</li>
            <#assign var4=[1,2,3,4,5,6,7,8,9,11,12,13]/>
            <li>${var4?chunk(4)?size}</li>

            <#list var4?chunk(4)?last as item>
                <font color="red">${item}</font>
            </#list>
        </ul>

        <ul>

            <li>其他内建函数</li>
            <li>${var5?has_content?string("yes","no")}</li>
            <li>${("1"+"2")?eval?is_number?string('yes','no')}</li>

        </ul>







    </div>

    <h1>macro,nested,return :实战demo</h1>
    <h2>macro 宏指令</h2>
    <li>栗子1：无参的macro</li>
    <div>
        <#macro test>
            <font color="red">我是无参的macro</font>
        </#macro>
        <@test/>


    </div>
    <li>栗子2：有参的macro</li>
    <div>
        <#macro test param1 param2>
            <font color="red">我是有参的macro，param1=${param1},param2=${param2}</font>
        </#macro>
        <@test param1="java" param2="python"/>
    </div>

    <li>栗子3：有默认参数的macro</li>
    <div>
        <#macro test param1 param2="python">
            <font color="red">我是有默认值的macro，param1=${param1},param2=${param2}</font>
        </#macro>
        <@test param1="java"/>
    </div>

    <li>栗子4：有多个参数的macro</li>
    <div>

        <#macro test param1 param2 paramExt...>
            <font color="red">我是有参数的macro，param1=${param1},param2={param2}</font><br>
            <font color="aqua">$paramExt['param3']}</font>
        </#macro>
        <@test param1="java" param2="python" param3="javaScripe" param4="PHP"/>
    </div>

    <h2>nest</h2>
    <div>
        <ul>
            <#macro test param1="java">
                ${param1}<br>
                <#nested param1,"我的nested参数"/><br>
            </#macro>
            <li>调用</li>

            <div>
                <@test param1="java";loopVar1,loopVar2>
                     <font color="red">hello,${loopVar1},${loopVar2}<br></font>
                </@test>
            <@test param1="pythhon";loopVar1>
                hello,${loopVar1}
            </@test>
            </div>

        </ul>
    </div>

    <h2>函数</h2>
    <div>
        <ul>
            <#function doAdd param1 param2>
                <#return param1+param2/>
            </#function>

            <li>调用</li>
            <div>${doAdd(100,200)}</div>
        </ul>
    </div>


    </body>


</html>